<template>
	<view class="container">
		<view class="per-yuyue-head">
			<view class="per-yuyue-headItem" @click="changepart(0)" :class="[showNum == 0?'per-yuyue-headItemShow':'']">待就诊</view>
			<view class="per-yuyue-headItem" @click="changepart(1)" :class="[showNum == 1?'per-yuyue-headItemShow':'']">已就诊</view>
			<view class="per-yuyue-headItem" @click="changepart(-1)" :class="[showNum == -1?'per-yuyue-headItemShow':'']">已取消</view>
		</view>
		<view class="per-yuyue-con">
			<view v-if="showNum == 0" class="per-yuyue-conNav">
				<view class="per-yuyue-consub" v-if="orderList.length > 0">
					<view class="yy-su-con" v-for="(item,index) in orderList" :key="index" @click="orderdetail(item.id)">
						<view class="porson-pageyuyue-dai">
							<image src="../../ic_daijiuzhen.png" mode="widthFix"></image>
						</view>
						<view class="yy-su-con-title">
							<text>预约号</text>
						</view>
						<view class="yy-su-con-num">
							<text class="yy-su-con-num">{{item.code}}</text>
						</view>
						<view class="yy-su-con-list">
							<view class="yy-su-con-item">
								<text>候诊时间</text>
								<text class="yy-su-con-Sitem">{{item.make_time}}</text>
							</view>
							<view class="yy-su-con-item">
								<text>就诊科室</text>
								<text>{{item.department_name}}</text>
							</view>
							<view class="yy-su-con-item">
								<text>就诊医生</text>
								<text>{{item.nickname}}</text>
							</view>
						</view>
					</view>
				</view>
				<view v-else class="per-yuyue-wait">
					<view class="per-yuyue-waitImg">
						<image src="../../static/img_yuyue.png" mode="widthFix"></image>
					</view>
					<text>您还没有相关预约</text>
				</view>
			</view>
			<view  v-if="showNum == 1" class="per-yuyue-conNav">
				<view class="per-yuyue-consubsucc" v-if="orderList.length > 0">
					<view class="yy-su-con" v-for="(item,index) in orderList" :key="index" @click="orderdetail(item.id)" >
						<view class="porson-pageyuyue-dai">
							<image src="../../static/img_dai.png" mode="widthFix"></image>
						</view>
						<view class="yy-su-con-list">
							<view class="yy-su-con-item">
								<text>候诊时间</text>
								<text class="yy-su-con-Sitem">{{item.make_time}}</text>
							</view>
							<view class="yy-su-con-item">
								<text>就诊科室</text>
								<text>{{item.department_name}}</text>
							</view>
							<view class="yy-su-con-item">
								<text>就诊医生</text>
								<text>{{item.nickname}}</text>
							</view>
						</view>
					</view>
				</view>
				<view v-else class="per-yuyue-wait">
					<view class="per-yuyue-waitImg">
						<image src="../../static/img_yuyue.png" mode="widthFix"></image>
					</view>
					<text>您还没有相关预约</text>
				</view>
			</view>
			<view  v-if="showNum == -1" class="per-yuyue-conNav">
				<view class="per-yuyue-consubcel" v-if="orderList.length > 0">
					<view class="yy-su-con"  v-for="(item,index) in orderList" :key="index" @click="orderdetail(item.id)">
						<view class="porson-pageyuyue-dai">
							<image src="../../static/img_can.png" mode="widthFix"></image>
						</view>
						<view class="yy-su-con-list">
							<view class="yy-su-con-item">
								<text>候诊时间</text>
								<text class="yy-su-con-Sitem">{{item.make_time}}</text>
							</view>
							<view class="yy-su-con-item">
								<text>就诊科室</text>
								<text>{{item.department_name}}</text>
							</view>
							<view class="yy-su-con-item">
								<text>就诊医生</text>
								<text>{{item.nickname}}</text>
							</view>
						</view>
					</view>
				</view>
				<view v-else class="per-yuyue-wait">
					<view class="per-yuyue-waitImg">
						<image src="../../static/img_yuyue.png" mode="widthFix"></image>
					</view>
					<text>您还没有相关预约</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import app from '../../App.vue'
	export default{
		data(){
			return{
				showNum:0,
				waitImg:0,
				apge:1,
				orderList:[]
			}
		},
		onLoad() {
			this.getbooking()
		},
		methods:{
			changepart(num){
				this.showNum = num
				this.orderList = []
				this.getbooking()
			},
			getbooking(){
				let that = this,
				data = {
					status:that.showNum == 0?0:that.showNum,
					page:that.apge,
					per_page:10
				}
				app.post('api/order/getOrderList',data).then(res=>{
					if(res.code == 1){
						that.orderList = res.data.data
						if(res.data.data == ''){
							uni.showToast({
								title: '暂无数据',
								icon: 'none',
								mask: true
							})
						}
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							mask: true
						})
					}
				}).catch(err=>{
					uni.showToast({
						title: err.msg,
						icon: 'none',
						mask: true
					})
				})
			},
			orderdetail(id){
				uni.showLoading({
					title:'加载中',
					success() {
						setTimeout(function(){
							uni.navigateTo({
								url:'/pages/person/detail?order_id='+id
							})
						},1300)
					}
				})
			}
		}
	}
</script>

<style>
	@import url("../../common/peryuyue.css");
</style>
